<template>
	<div class="mallorder">
		<el-form :inline="true" :model="formData" class="demo-form-inline">
			<el-form-item>
				<el-input v-model="formData.name" placeholder="商品名称" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-input v-model="formData.mobile" placeholder="收货人手机号" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-input v-model="formData.orderNo" placeholder="订单号" clearable></el-input>
			</el-form-item>
			<el-form-item>
				<el-select v-model="formData.orderStatus" placeholder="订单状态" clearable>
					<el-option label="待付款" value="0"></el-option>
					<el-option label="已付款" value="1"></el-option>
					<el-option label="已发货" value="2"></el-option>
					<el-option label="已确认" value="3"></el-option>
					<el-option label="已取消" value="4"></el-option>
					<el-option label="已退款" value="5"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-select v-model="formData.orderType" placeholder="订单类型" clearable>
					<el-option label="普通订单" value="0"></el-option>
					<el-option label="秒杀订单" value="1"></el-option>
					<el-option label="虚拟商品订单" value="2"></el-option>
					<el-option label="红包拼团订单" value="3"></el-option>
					<el-option label="金豆订单" value="5"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
			  <el-select v-model="formData.activityStatus" placeholder="活动状态" clearable>
			    <el-option label="待开团" value="1"></el-option>
			    <el-option label="拼团成功" value="2"></el-option>
			    <el-option label="拼团失败" value="-2"></el-option>
			  </el-select>
			</el-form-item>
			<el-form-item>
				<el-select v-model="formData.isAfterSale" placeholder="是否售后" clearable>
					<el-option label="未申请售后" value="0"></el-option>
					<el-option label="已申请售后" value="1"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-select v-model="formData.settleStatus" placeholder="结算状态" clearable>
					<el-option label="未结算" value="0"></el-option>
					<el-option label="已结算" value="1"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-date-picker v-model="date" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" :default-time="['00:00:00', '23:59:59']"  range-separator="至" start-placeholder="开始日期"
				 end-placeholder="结束日期" style="width: 400px;">
				</el-date-picker>
			</el-form-item>

			<el-form-item>
				<el-button type="primary" @click="onSearch" icon="el-icon-search">搜索 </el-button>
			</el-form-item>
		</el-form>


		<div class="total">
			<ul>
				<li>
					<span>实际支付现金总数</span>
					<span class="nums">{{orderSumDTO.sumActualPayAmount}}</span>
				</li>
				<li>
					<span>实际糖果抵扣总数</span>
					<span class="nums">{{orderSumDTO.sumActualPaySweet}}</span>
				</li>
				<li>
					<span>总金额</span>
					<span class="nums">{{orderSumDTO.sumTotalAmount}}</span>
				</li>
				<li>
					<el-button type="primary" @click="exportExcel()" icon="el-icon-bottom">导出表格</el-button>
				</li>
			</ul>
		</div>

		<el-table :data="tableData" style="width: 100%" border>
			<el-table-column prop="orderProductName" label="商品名称" align="center" width="120" show-overflow-tooltip></el-table-column>
			<el-table-column prop="orderProductImgUrl" label="商品图片" align="center" width="100">
				<template slot-scope="scope">
					<img :src="scope.row.orderProductImgUrl" alt="" style="width: 60px;">
				</template>
			</el-table-column>
			<el-table-column prop="merchantName" label="门店名称" align="center" width="120" show-overflow-tooltip></el-table-column>
			<el-table-column prop="deliveryMobile" label="收货人手机号" align="center" width="140"></el-table-column>
			<el-table-column prop="deliveryName" label="收货人姓名" align="center" width="120" show-overflow-tooltip></el-table-column>
			<el-table-column prop="orderNo" label="订单号" align="center" width="260"></el-table-column>
			<el-table-column prop="orderStatus" label="订单状态" align="center">
				<template slot-scope="scope">
					<span>{{orderStatusList[scope.row.orderStatus]}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="orderType" label="订单类型" align="center" width="140">
				<template slot-scope="scope">
					<span>{{ORDERTYPE[scope.row.orderType]}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="actualPayAmount" label="实际支付金额" align="center" width="160"></el-table-column>
			<el-table-column prop="totalAmount" label="总金额 " align="center"></el-table-column>
			<el-table-column prop="actualPayGoldenBean" label="实际支付金豆" align="center" width="160"></el-table-column>
			<el-table-column prop="actualSettledGoldenBean" label="实际应结算金豆数" align="center" width="160"></el-table-column>
			<el-table-column prop="actualPaySweet" label="实际支付糖果" align="center" width="120"></el-table-column>
			<el-table-column prop="actualSettledSweets" label="实际应结算糖果" align="center" width="120"></el-table-column>
			<el-table-column prop="buyNumber" label="商品数量" align="center"></el-table-column>
			<el-table-column prop="deliveryType" label="取货方式" align="center">
				<template slot-scope="scope">
					<span>{{scope.row.deliveryType==1?'快递配送':scope.row.deliveryType==3?'同城配送':scope.row.deliveryType==2?'门店自提':''}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="settleStatus" label="结算状态 " align="center">
				<template slot-scope="scope">
					{{scope.row.settleStatus==0?'未结算':'已结算'}}
				</template>
			</el-table-column>
			<el-table-column prop="isAfterSale" label="是否申请售后" align="center" width="120">
				<template slot-scope="scope">
					<span>{{scope.row.isAfterSale?'已申请售后':'未申请售后'}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="orderTime" label="下单时间" align="center" width="170"></el-table-column>

			<el-table-column label="操作" width="260" fixed="right" header-align="center" align="center">
				<template slot-scope="scope">
					<el-button type="primary" size="small" v-if="(scope.row.isAfterSale==false&&scope.row.orderStatus==1&&scope.row.orderType != 2&&scope.row.orderType!=3) || (scope.row.orderType==3&&scope.row.orderStatus==1&&scope.row.activityStatus==2)" @click="fahuo(scope.row)">
						{{scope.row.deliveryType==2?'提货':'发货'}}
					</el-button>
					<el-button type="primary" size="small" @click="viewOrderDetail(scope.row)">订单详情</el-button>
					<el-button type="primary" size="small" v-show='scope.row.orderStatus==1' @click="edit(scope.row)">编辑</el-button>
				</template>
			</el-table-column>
		</el-table>

		<div class="pages">
			<el-pagination :page-size="formData.size" :current-page="formData.page" layout="prev, pager, next,total,jumper"
			 :total="total" background @current-change="handleCurrentChange">
			</el-pagination>
		</div>

		<el-dialog title="订单详情" :visible.sync="drawer" width="100%">
			<el-card class="box-card">
				<div slot="header" class="clearfix">
					<span>基础信息</span>
				</div>
				<el-row>
					<el-col :span="8" class="mb20">
						<span>订单号：</span>
						<span>{{orderData.orderNo}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单状态：</span>
						<el-tag type="primary" effect="dark" size="small">{{orderStatusList[orderData.orderStatus]}}</el-tag>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>门店名称：</span>
						<span>{{orderData.merchantName}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>下单人手机号：</span>
						<span>{{orderData.userPhone}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>商家取货联系电话：</span>
						<span>{{orderData.businessPhone}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>数量：</span>
						<span>{{orderData.buyNumber}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>优惠金额：</span>
						<span>{{orderData.discountAmount}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单运费：</span>
						<span>{{orderData.freightAmount}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>糖果平均价：</span>
						<span>{{orderData.sweetAveragePrice}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>糖果抵扣的现金价：</span>
						<span>{{orderData.sweetDeductPrice}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>实际支付金豆：</span>
						<span>{{orderData.actualPayGoldenBean}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>实际应结算金豆数：</span>
						<span>{{orderData.actualSettledGoldenBean}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>金豆平均价：</span>
						<span>{{orderData.goldenBeanAveragePrice}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>金豆抵扣的现金价：</span>
						<span>{{orderData.goldenBeanDeductPrice}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>总金额：</span>
						<span>{{orderData.totalAmount}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>成本总价：</span>
						<span>{{orderData.totalCostAmount}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>实付金额：</span>
						<span style="color: #ed1324;font-size: 28px;"><i style="font-size: 20px;">¥</i>
							{{orderData.actualPayAmount}} + <i style="font-size: 20px;" class="el-icon-lollipop"></i>
							{{orderData.actualPaySweet}}</span>
					</el-col>

					<el-col :span="8" class="mb20">
						<span>商家取货门店地址：</span>
						<span>{{orderData.businessAddress}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单取消原因：</span>
						<span>{{orderData.cancelReason}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单取消时间：</span>
						<span>{{orderData.cancelTime}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>售后单号：</span>
						<span>{{orderData.afterSaleNo}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>确认收货后申请售后的最晚时间：</span>
						<span>{{orderData.afterSaleDeadlineTime}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>售后单号：</span>
						<span>{{orderData.afterSaleNo}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>确认收货后申请售后的最晚时间：</span>
						<span>{{orderData.afterSaleDeadlineTime}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单是否入账到商家：</span>
						<span>{{orderData.isAccounted?'是':'否'}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单是否已申请售后：</span>
						<span>{{orderData.isAfterSale?'是':'否'}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>下单时间：</span>
						<span>{{orderData.orderTime}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单类型：</span>
						<span>{{ORDERTYPE[orderData.orderType]}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
					  <span>活动状态：</span>
					  <span>{{ACTIVITYSTATUS[orderData.activityStatus]}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单支付方式：</span>
						<span>{{orderData.orderType==1?'RMB':orderData.orderType==2?'糖果+RMB':'糖果'}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>支付时间：</span>
						<span>{{orderData.paymentTime}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单现金支付渠道：</span>
						<span>{{orderData.pricePayType==1?'微信':orderData.pricePayType==2?'支付宝':'银行卡'}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>退款后生成的交易编号：</span>
						<span>{{orderData.refundId}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>退款返回的消息：</span>
						<span>{{orderData.refundMsg}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>结算状态：</span>
						<span>{{orderData.settleStatus==0?'未结算':'已结算'}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>订单结算时间：</span>
						<span>{{orderData.settleTime}}</span>
					</el-col>
					<el-col :span="16" class="mb20">
						<span>支付后生成的交易编号：</span>
						<span>{{orderData.transactionId}}</span>
					</el-col>
				</el-row>
			</el-card>
			<el-card class="box-card">
				<div slot="header" class="clearfix">
					<span>商品</span>
				</div>
				<el-table :data="mallData" style="width: 100%" border>
					<el-table-column prop="orderId" label="订单ID" align="center">
					</el-table-column>
					<el-table-column prop="productName" label="商品名称" align="center">
					</el-table-column>
					<el-table-column prop="productImageUrl" label="商品图片" align="center">
						<template slot-scope="scope">
							<el-image :src="scope.row.productImageUrl" style="width: 60px;height:60px"></el-image>
						</template>
					</el-table-column>
					<el-table-column prop="productCode" label="商品货号" align="center">
					</el-table-column>
					<el-table-column prop="productSkuSpec" label="商品规格属性描述" align="center">
					</el-table-column>
					<el-table-column prop="productUnit" label="商品数量" align="center">
					</el-table-column>
					<el-table-column prop="productUnitPrice" label="单价(元)" align="center">
					</el-table-column>
					<el-table-column prop="sweetDeductPrice" label="糖果抵扣价" align="center">
					</el-table-column>
					<el-table-column prop="actualSweet" label="实际糖果抵扣" align="center">
					</el-table-column>
					<el-table-column prop="actualAmount" label="实际支付金额" align="center">
					</el-table-column>
				</el-table>
			</el-card>
			<el-card class="box-card" v-if="couponListVo">
				<div slot="header" class="clearfix">
					<span>优惠券信息</span>
				</div>
				<el-row>
					<el-col :span="8" class="mb20">
						<span>ID：</span>
						<span>{{couponListVo.id}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>优惠券名称：</span>
						<span>{{couponListVo.type}}</span>
					</el-col>

					<el-col :span="8" class="mb20">
						<span>类型：</span>
						<span>{{couponListVo.key=='plat_task_coupon'?'任务优惠卷轴':''}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>抵扣金额：</span>
						<span>{{couponListVo.deductionPrice}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>满减金额：</span>
						<span>{{couponListVo.minPrice}}</span>
					</el-col>
				</el-row>
			</el-card>

			<el-card class="box-card" v-if="orderData.orderType != 2">
				<div slot="header" class="clearfix">
					<span>收货信息</span>
				</div>
				<el-row>
					<el-col :span="8" class="mb20">
						<span>收货人姓名：</span>
						<span>{{orderData.deliveryName}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>收货人电话：</span>
						<span>{{orderData.deliveryMobile}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>物流公司：</span>
						<span>{{orderData.courierName}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>物流单号：</span>
						<span>{{orderData.courierNo}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>收货地址(详细地址)：</span>
						<span>{{orderData.deliveryStreet}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>收货地址省市区：</span>
						<span>{{orderData.deliveryRegion}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>确认收货时间：</span>
						<span>{{orderData.confirmTime}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>发货时间：</span>
						<span>{{orderData.deliveryTime}}</span>
					</el-col>
					<el-col :span="8" class="mb20">
						<span>取货方式：</span>
						<span>{{orderData.deliveryType==1?'快递配送':orderData.deliveryType==2?'同城配送':orderData.deliveryType==3?'门店自提':''}}</span>
					</el-col>
				</el-row>
				<el-row>
					<el-col>
						<el-button type="primary" size="small" v-if="orderData.orderStatus==2||orderData.orderStatus==3" @click="viewwuliu(orderData)">查询物流</el-button>
					</el-col>
				</el-row>
			</el-card>

			<el-card class="box-card">
				<div slot="header" class="clearfix">
					<span>买家备注</span>
				</div>
				<el-row>
					<el-col :span="8" class="mb20">
						<span>订单备注(买家)：</span>
						<span>{{orderData.memo}}</span>
					</el-col>
				</el-row>
			</el-card>

			<el-card class="box-card">
				<div slot="header" class="clearfix">
					<span>卖家备注</span>
				</div>
				<el-row>
					<el-col :span="8" class="mb20">
						<span>订单备注(卖家)：</span>
						<span>{{orderData.orderComment}}</span>
					</el-col>
				</el-row>
			</el-card>
		</el-dialog>

		<el-dialog title="快递配送" :visible.sync="fahuoVisible" width="30%">
			<el-form ref="fahuo" :model="fahuoData" label-width="80px">
				<el-form-item label="物流公司">
					<el-select v-model="fahuoData.courierName" placeholder="请选择物流公司">
						<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.label">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="物流单号">
					<el-input v-model="fahuoData.courierNo" clearable></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="fahuoSubmit">确 定</el-button>
			</span>
		</el-dialog>

		<el-dialog title="修改订单收货信息" :visible.sync="receiptInfoVisible" width="40%">
			<el-form ref="receiptInfo" :model="receiptInfoData" label-width="120px">
				<el-form-item label="订单号">
					<el-input v-model="receiptInfoData.orderNo" clearable></el-input>
				</el-form-item>
				<el-form-item label="收货地址">
					<el-input v-model="receiptInfoData.deliveryStreet" clearable></el-input>
				</el-form-item>
				<el-form-item label="收货人电话">
					<el-input v-model="receiptInfoData.deliveryMobile" clearable></el-input>
				</el-form-item>
				<el-form-item label="收货人姓名">
					<el-input v-model="receiptInfoData.deliveryName" clearable></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="receiptSubmit">确 定</el-button>
			</span>
		</el-dialog>

		<el-dialog title="物流详情" :visible.sync="wuliuVisible" width="45%">
			<el-timeline :reverse="reverse">
				<el-timeline-item v-for="(activity, index) in activities" :key="index" :timestamp="activity.time">
					{{activity.status}}
				</el-timeline-item>
			</el-timeline>
		</el-dialog>

	</div>
</template>

<script>
	import axios from 'axios';
	export default {
		data() {
			return {
				formData: {
					name:'',
					mobile: '',
					orderNo: '',
					orderStatus: '',
					orderType: '',
					activityStatus:'',
					settleStatus: '',
					startDate: '',
					isAfterSale:'0',
					endDate: this.date != null ? this.date[1] : '',
					size: 10,
					page: 1
				},

				date: [this.getstartNowTime(), this.getNowTime()],
				total: 0,
				tableData: [],
				drawer: false,
				direction: 'rtl',
				orderData: '',
				mallData: [],
				orderSumDTO: {
					sumActualPayAmount: '',
					sumActualPaySweet: '',
					sumTotalAmount: ''
				},

				fahuoVisible: false,
				fahuoData: {
					courierName: '',
					courierNo: '',
					id: ''
				},
				receiptInfoVisible: false,
				receiptInfoData: {
					"deliveryMobile": "",
					"deliveryName": "",
					"deliveryStreet": "",
					"id": '',
					"orderNo": ""
				},
				orderStatusList: {
					'0': '待付款',
					'1': '已付款',
					'2': '已发货',
					'3': '已确认',
					'4': '已取消',
					'5': '已退款'
				},
				ORDERTYPE: {
				  0: '普通订单',
				  1: '秒杀订单',
				  2: '虚拟商品订单',
				  3: '红包拼团订单',
				  5: '金豆订单'
				},
				ACTIVITYSTATUS: {
				  '0': '初始状态',
				  '-1': '参团失败',
				  '1': '参团成功，待开团',
				  '2': '拼团成功',
				  '-2': '拼团失败'
				},
				wuliuVisible: false,
				reverse: false,
				activities: [],
				options: [{
					value: '0',
					label: '顺丰速运'
				}, {
					value: '1',
					label: '中国邮政'
				}, {
					value: '2',
					label: '圆通速递'
				}, {
					value: '3',
					label: '中通快递'
				}, {
					value: '4',
					label: '申通快递'
				}, {
					value: '5',
					label: '宅急送'
				}, {
					value: '6',
					label: '联邦物流'
				}, {
					value: '7',
					label: '韵达快递'
				}, {
					value: '8',
					label: '京东快递'
				}, {
					value: '9',
					label: '百世快递'
				}, {
					value: '10',
					label: '其他快递'
				}],
				couponListVo: null
			}
		},
		mounted() {
			this.getData();
		},
		methods: {
			//导出表单
			exportExcel() {
				axios({
					method: 'post',
					url: this.$api.orderExcelExport,
					data: this.formData,
					responseType: 'blob'
				}).then(function(res) {
					var data = res.data;
					if (!data) {
						return
					}
					const link = document.createElement('a');
					let blob = new Blob([data], {
						type: 'application/vnd.ms-excel'
					});
					link.style.display = 'none';
					link.href = URL.createObjectURL(blob);

					link.setAttribute('download', '商品订单' + '.xlsx');
					document.body.appendChild(link);
					link.click();
					document.body.removeChild(link);
				});
			},
			getstartNowTime(){
				let now = new Date();
				let year = now.getFullYear(); //得到年份
				let month = now.getMonth(); //得到月份
				let date = now.getDate(); //得到日期
				month = month + 1;
				month = month.toString().padStart(2, "0");
				date = date.toString().padStart(2, "0");
				let defaultDate = `${year}-${month}-${date} 00:00:00`;
				return defaultDate;
			},
			//默认当天时间
			getNowTime() {
				let now = new Date();
				let year = now.getFullYear(); //得到年份
				let month = now.getMonth(); //得到月份
				let date = now.getDate(); //得到日期
				month = month + 1;
				month = month.toString().padStart(2, "0");
				date = date.toString().padStart(2, "0");
				let defaultDate = `${year}-${month}-${date} 23:59:59`;
				return defaultDate;
			},
			//获取订单列表
			getData() {
				this.formData.startDate = this.date != null ? this.date[0] : '';
				this.formData.endDate = this.date != null ? this.date[1] : '';
				this.formData.merchantId = localStorage.getItem('merchantId');
				this.$http.get(this.$api.mallOrderList, this.formData).then(res => {
					if (res.code == 0) {
						this.tableData = res.data.orderListDto;
						if (res.data.orderSumDTO != null) {
							this.orderSumDTO = res.data.orderSumDTO
						} else {
							this.orderSumDTO = {
								sumActualPayAmount: 0,
								sumActualPaySweet: 0,
								sumTotalAmount: 0
							}
						}
						this.total = res.extraInfo;
					}
				})
			},
			//搜索
			onSearch() {
				this.formData.startDate = this.date != null ? this.date[0] : '';
				this.formData.endDate = this.date != null ? this.date[1] : '';
				this.formData.page = 1;
				this.getData();
			},
			//分页
			handleCurrentChange(val) {
				this.formData.page = val;
				this.getData();
			},
			//查询订单详情
			viewOrderDetail(row) {
				this.$http.get(this.$api.mallOrderDetails, {
					orderNo: row.orderNo
				}).then(res => {
					if (res.code == 0) {
						this.drawer = true;
						this.orderData = res.data.order;
						this.mallData = res.data.orderProduct;
						this.couponListVo = res.data.couponListVo;
					}
				})
			},
			//draw关闭
			back() {
				this.drawer = false;
			},
			//添加物流
			fahuo(row) {
				if (row.deliveryType == 2) {
					this.$confirm('确认商品提货, 是否继续?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						this.$http.put(this.$api.orderPickUp + '/' + row.id).then(res => {
							if (res.code == 0) {
								this.$message({
									type: 'success',
									message: '提货成功!'
								});
								this.getData();
							} else {
								this.$message({
									type: 'success',
									message: '提货失败!' + res.msg
								});
							}
						})
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '已取消删除'
						});
					});
				} else {
					if (row.courierName && row.courierNo) {
						this.fahuoData.courierName = row.courierName
						this.fahuoData.courierNo = row.courierNo
					} else {
						this.fahuoData.courierName = ''
						this.fahuoData.courierNo = ''
					}
					this.fahuoVisible = true;
					this.fahuoData.id = row.id;
				}

			},
			//物流提交
			fahuoSubmit() {
				if (!this.fahuoData.courierName || !this.fahuoData.courierNo) {
					this.$message.error('请确认物流信息填写完整？');
					return false
				}
				this.$http.post(this.$api.mallOrderDeliver, this.fahuoData).then(res => {
					if (res.code == 0) {
						this.$message({
							type: 'success',
							message: '发货成功'
						})
						this.getData();
						this.fahuoVisible = false;
					} else {
						this.$message({
							type: 'error',
							message: '发货失败,' + res.msg
						})
					}
				})
			},
			//编辑
			edit(row) {
				this.receiptInfoData = {
					"deliveryMobile": row.deliveryMobile,
					"deliveryName": row.deliveryName,
					"deliveryStreet": row.deliveryStreet,
					"id": row.id,
					"orderNo": row.orderNo
				}
				this.receiptInfoVisible = true;
			},
			//收货信息提交
			receiptSubmit() {
				this.$http.put(this.$api.mallOrderUpdate, this.receiptInfoData).then(res => {
					if (res.code == 0) {
						this.$message({
							type: 'success',
							message: '修改成功'
						});
						this.getData();
						this.receiptInfoVisible = false;
					} else {
						this.$message({
							type: 'error',
							message: '修改失败'
						})
					}
				})
			},
			//查询物流
			viewwuliu(row) {
				this.$http.get(this.$api.mallOrderLogistics, {
					mobile: row.deliveryMobile,
					number: row.courierNo
				}).then(res => {
					if (res.data.resp.RespCode == 0) {
					  this.wuliuVisible = true;
					  this.activities = res.data.data.list;
					} else {
					  this.$message.error('没有可查询的物流信息！');
					}
				})
			}
		}
	}
</script>

<style scoped>
	.mallorder {
		padding: 15px;
	}

	.pages {
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 30px;
	}

	.mallorder>>>.el-card__header {
		font-weight: bold;
	}

	.box-card {
		margin-bottom: 15px
	}

	.mb20 {
		height: 40px;
		line-height: 40px;
	}

	.total ul {
		display: flex;
		justify-content: flex-end;
		align-items: center;
		height: 50px;
		color: #555;
	}

	.total ul li {
		margin: 0 15px;
	}

	.total ul li .nums {
		font-size: 24px;
		font-weight: bold;
		color: red;
		padding-left: 8px;
	}
</style>
